from bs4 import BeautifulSoup

html = '''
    <html>
        <head>
            <title>测试美味的Soup</title>
        </head>
        <body>
            <div id="#d1">测试d1</div>
            <div id="#d2">测试d2</div>
            <ul>
                <li>测试列表01</li>
                <li>测试列表02</li>
                <li>测试列表03</li>
                <li>测试列表04</li>
                <li>测试列表05</li>
                <li>测试列表06</li>
            </ul>

            <ul id='ut'>
                <li class="ti">再次测试列表01</li>
                <li class="ti">再次测试列表02</li>
                <li class="ti">再次测试列表03</li>
                <li class="ti">再次测试列表04</li>
                <li class="ti">再次测试列表05</li>
                <li class="ti">再次测试列表06</li>
            </ul>
        </body>
    </html>
'''

bs = BeautifulSoup(html,'lxml')
print(bs.title)

print(bs.select('li.ti'))
for i in bs.select('li.ti'):
    print(i.text,i.get('class'))

print(bs.select('#ut.li'))

